package edu.uclm.esi.tysweb.ajedrez.persistencia;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;

import edu.uclm.esi.tysweb.ajedrez.dominio.Jugador;

public class DAOJugador {
	
	public static void registrar(Jugador j, String pwd) throws SQLException {
		Connection bd=Broker.get().getDB("root", "");
		try {
			String sql="{call insertarUsuario (?, ?, ?, ?, ?)}";
			CallableStatement cs=bd.prepareCall(sql);
			cs.setString(1, j.getLogin());
			cs.setString(2, pwd);
			cs.registerOutParameter(3, java.sql.Types.VARCHAR);
			cs.registerOutParameter(4, java.sql.Types.VARCHAR);
			cs.registerOutParameter(5, java.sql.Types.VARCHAR);
			cs.executeUpdate();
			String exito=cs.getString(3);
			String q1=cs.getString(4);
			String q2=cs.getString(5);
			exito.toString();
		}
		catch (SQLException e) {
			throw e;
		}
		finally {
			bd.close();
		}
	}

}
